from fastapi import APIRouter, Request
from app.parameter import PuttyChatParam,KnowledgeChatParam,SQLChatParam
from app.service import ChatService
from app.utils import getUserInfo

router = APIRouter(tags=["群组路由"])
from utils import DEBUG


@router.post("/chat/putty")
async def chatPutty(puttyChatParam :PuttyChatParam,request: Request):
    return ChatService.puttyChat(puttyChatParam)

@router.post("/chat/knowledge")
async def chatKnowledge(knowledgeChatParam :KnowledgeChatParam,request: Request):
    userId = getUserInfo(request)
    return ChatService.knowledgeChat(knowledgeChatParam, userId)

# 不支持上下文
@router.post("/chat/sql")
async def chatSQL(sqlChatParam :SQLChatParam,request: Request):
    userId = getUserInfo(request)
    return ChatService.sqlChat(sqlChatParam, userId)

# 不支持上下文
@router.post("/chat/database")
async def chatSQL(sqlChatParam :SQLChatParam,request: Request):
    userId = getUserInfo(request)
    return ChatService.databaseChat(sqlChatParam, userId)